home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr52 / syscheck.zip / SYSCHECK.PAS < prev   
Pascal/Delphi Source File  |  1993-05-13  |  4KB  |  117 lines

  1. { Program : SYSCHECK.PAS
  2.  
  3.   Purpose : Insure that sufficient file handles and memory is available
  4.             prior to running a Clipper program.  SYSCHECK is esp. useful
  5.             for network Clipper apps.  An optional error log provides
  6.             error tracking.
  7.  
  8.   Language: Turbo Pascal v4.0
  9.  
  10.   Author  : Vick Perry
  11.  
  12.   Date    : 1/5/91
  13.  
  14.   SYSCHECK is released into the public domain.
  15. }
  16.  
  17. program syscheck;
  18.  
  19. uses
  20.    Dos,
  21.    Crt,
  22.    Printer;
  23.  
  24. var
  25.    req_handles   : word;      {number of file handles needed - parameter 1}
  26.    req_memory    : word;      {amount of regular memory needed - parameter 2}
  27.    userid        : string[20];{name of user - parameter 3}
  28.    errorfile     : string[80];{filename/path for error file - parameter 4}
  29.    avail_handles : word;      {number of file handles available}
  30.    avail_memory  : word;      {amount of regular memory available}
  31.    e_level       : byte;      {DOS ERRORLEVEL set upon exiting}
  32.  
  33.  
  34. {bad parameters were passed to SYSCHECK - show the help screen}
  35. procedure showhelp;
  36.    begin
  37.       writeln;
  38.       writeln('Syntax :  SYSCHECK <handles> <memory> [<userid> [<errorfile>]');
  39.       writeln;
  40.       writeln('  where: <handles>   - Number of file handles required (256 max).');
  41.       writeln('         <memory>    - Memory required (in kilobytes, 640 max).');
  42.       writeln('         <userid>    - Optional - user ID to report to screen and');
  43.       writeln('                       error file (max length = 20 characters).');
  44.       writeln('         <errorfile> - Optional - path/name of error text file');
  45.       writeln('                       (max length = 50 characters).');
  46.       writeln;
  47.       writeln('SYSCHECK returns the following DOS ERRORLEVEL codes:');
  48.       writeln('');
  49.       writeln('            0     File handles and memory are sufficient');
  50.       writeln('            1     Not enough available file handles');
  51.       writeln('            2     Not enough available memory');
  52.       writeln('            3     Invalid parameters passed to SYSCHECK');
  53.       writeln;
  54.    end;
  55.  
  56. {check and load the command line parameters into global variables}
  57. function good_para(p1,p2,p3,p4:string):boolean;
  58. var
  59.    code: integer;
  60. begin
  61.    good_para := false;
  62.    if ((paramCount>0) and (length(paramstr(1))>0) and (length(paramstr(2))>0)) then
  63.       begin
  64.          val(paramstr(1),req_handles,code);
  65.          if ((req_handles>=0) and (req_handles<=256) and (code=0)) then
  66.             begin
  67.                val(paramstr(2),req_memory,code);
  68.                if ((req_memory>=0) and (req_memory<=256) and (code=0)) then
  69.                   begin
  70.                      good_para := true;
  71.                      {load the userid and error file name, if any}
  72.                      userid := paramstr(3);
  73.                      errorfile := paramstr(4);
  74.                   end;
  75.             end;
  76.       end;
  77.  
  78.  
  79.  
  80.    if (good_para = false) then
  81.       e_level := 3
  82.       showhelp;
  83.    end;
  84. end;
  85.  
  86.  
  87.  
  88.  
  89.  
  90. {=============================  MAIN PROGRAM ===========================}
  91.  
  92. begin
  93.    {assign variables}
  94.    req_handles   := 0;
  95.    req_memory    := 0;
  96.    userid        := '';
  97.    errorfile     := '';
  98.    avail_handles := 0;
  99.    avail_memory  := 0;
  100.    e_level       := 0;
  101.  
  102.    writeln;
  103.    writeln('SYSCHECK is checking available file handles and memory');
  104.    writeln;
  105.    if (good_para(paramstr(1),paramstr(2),paramstr(3),paramstr(4))=true) then
  106. {      avail_handles:=get_handles();
  107.       avail_memory:=get_memory()
  108. }
  109.    end;
  110.    halt(e_level);   {return an ERRORLEVEL code}
  111. end.
  112.  
  113.  
  114.  
  115.  
  116.  
  117.